package org.mathig.poker.hand;

import java.util.List;

import org.mathig.poker.Card;
import org.mathig.poker.PokerRank;
import org.mathig.poker.Rank;

public class Straight extends AbstractHand {

	protected List<Card> cards;

	public Straight(List<Card> cards) {
		this.cards = cards;
	}

	public Card getHighCard() {
		return cards.get(0);
	}

	public Rank getHighRank() {
		return getHighCard().getRank();
	}

	public String cards() {
		return cards.toString();
	}

	@Override
	public String toString() {
		return getHighRank() + "-high straight";
	}

	public int compareTo(Hand hand) {
		int compare = super.compareTo(hand);
		if (compare != 0)
			return compare;
		if (hand instanceof Straight) {
			Straight straight = (Straight) hand;
			return compareRanks(cards, straight.cards);
		}
		return compare;
	}

	public PokerRank getPokerRank() {
		return PokerRank.STRAIGHT;
	}

}
